/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.math.BigInteger;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Carito
 */
@Entity
@Table(name = "FORMATO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Formato.findAll", query = "SELECT f FROM Formato f"),
    @NamedQuery(name = "Formato.findByIdformato", query = "SELECT f FROM Formato f WHERE f.formatoPK.idformato = :idformato"),
    @NamedQuery(name = "Formato.findByDescripcion", query = "SELECT f FROM Formato f WHERE f.descripcion = :descripcion"),
    @NamedQuery(name = "Formato.findByNombre", query = "SELECT f FROM Formato f WHERE f.nombre = :nombre"),
    @NamedQuery(name = "Formato.findByIddato", query = "SELECT f FROM Formato f WHERE f.formatoPK.iddato = :iddato")})
public class Formato implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected FormatoPK formatoPK;
    @Size(max = 600)
    @Column(name = "DESCRIPCION")
    private String descripcion;
    @Size(max = 180)
    @Column(name = "NOMBRE")
    private String nombre;
    @JoinColumn(name = "IDDATO", referencedColumnName = "IDDATO", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Dato dato;

    public Formato() {
    }

    public Formato(FormatoPK formatoPK) {
        this.formatoPK = formatoPK;
    }

    public Formato(BigInteger idformato, BigInteger iddato) {
        this.formatoPK = new FormatoPK(idformato, iddato);
    }

    @XmlElement
    public FormatoPK getFormatoPK() {
        return formatoPK;
    }

    public void setFormatoPK(FormatoPK formatoPK) {
        this.formatoPK = formatoPK;
    }

    @XmlElement
    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    @XmlElement
    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    @XmlElement
    public Dato getDato() {
        return dato;
    }

    public void setDato(Dato dato) {
        this.dato = dato;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (formatoPK != null ? formatoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Formato)) {
            return false;
        }
        Formato other = (Formato) object;
        if ((this.formatoPK == null && other.formatoPK != null) || (this.formatoPK != null && !this.formatoPK.equals(other.formatoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Formato[ formatoPK=" + formatoPK + " ]";
    }
    
}
